Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Roc authors
3
*
4
* This Source Code Form is subject to the terms of the Mozilla Public
5
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
*/
8
9
//! @file roc_core/target_libuv/roc_core/thread.h
10
//! @brief Thread.
11
12
#ifndef ROC_CORE_THREAD_H_
13
#define ROC_CORE_THREAD_H_
14
15
#include <uv.h>
16
17
#include "
roc_core/atomic.h
"
18
#include "
roc_core/mutex.h
"
19
#include "
roc_core/noncopyable.h
"
20
21
namespace
roc
{
22
namespace
core {
23
24
//! Base class for thread objects.
25
class
Thread
:
public
NonCopyable
<Thread> {
26
public
:
27
//! Check if thread was started and can be joined.
28
//! @returns
29
//! true if start() was called and join() was not called yet.
30
bool
joinable
()
const
;
31
32
//! Start thread.
33
//! @remarks
34
//! Executes run() in new thread.
35
bool
start
();
36
37
//! Join thread.
38
//! @remarks
39
//! Blocks until run() returns and thread terminates.
40
void
join
();
41
42
protected
:
43
virtual
~Thread
();
44
45
Thread
();
46
47
//! Method to be executed in thread.
48
virtual
void
run
() = 0;
49
50
private
:
51
static
void
thread_runner_(
void
* ptr);
52
53
uv_thread_t thread_;
54
55
int
started_;
56
Atomic
joinable_;
57
58
Mutex
mutex_;
59
};
60
61
}
// namespace core
62
}
// namespace roc
63
64
#endif
// ROC_CORE_THREAD_H_
atomic.h
Atomic integer.
roc::core::Atomic
Atomic integer.
Definition:
atomic.h:21
roc::core::Mutex
Mutex.
Definition:
mutex.h:27
roc::core::NonCopyable
Base class for non-copyable objects.
Definition:
noncopyable.h:23
roc::core::Thread
Base class for thread objects.
Definition:
thread.h:25
roc::core::Thread::start
bool start()
Start thread.
roc::core::Thread::join
void join()
Join thread.
roc::core::Thread::run
virtual void run()=0
Method to be executed in thread.
roc::core::Thread::joinable
bool joinable() const
Check if thread was started and can be joined.
mutex.h
Mutex.
roc
Root namespace.
noncopyable.h
Non-copyable object.
roc_core
target_libuv
roc_core
thread.h
Generated by
1.9.5